package flexcommon.validators.support
{
	import flash.utils.Dictionary;
	
	import mx.resources.IResourceManager;
	import mx.resources.ResourceManager;
  
  [ResourceBundle("FlexCommon")]
	
	/**
   * Contains the routing number definitions for three countries: CA, US and GB.
   * 
   * @author Dimitrios Gianninas
   * @see RoutingCountryDefinition
   */
	public class RoutingNumberRules
	{
    private static var rb:IResourceManager = ResourceManager.getInstance();
    
  	// data fields
  	private static var countries:Dictionary;
  	
  	// static initalizer
  	initData();
  	
  	/**
  	 *  @private    
     *  Loads resources for this class.
     */
  	private static function initData():void 
    {
  		countries = new Dictionary();
  		var c1:RoutingCountryDefinition = new RoutingCountryDefinition();
  		c1.country = "US";
  		c1.length = 9;
  		c1.label = "Routing Number";
  		c1.description = rb.getString( "FlexCommon", "ROUTING_NBR_US_TIP" );
  		countries["US"] = c1;
  		
  		var c2:RoutingCountryDefinition = new RoutingCountryDefinition();
  		c2.country = "CA";
  		c2.length = 8;
  		c2.label = "Inst.ID/Trans#";
  		c2.description = rb.getString( "FlexCommon", "ROUTING_NBR_CA_TIP" );
  		countries["CA"] = c2;
  		
  		var c3:RoutingCountryDefinition = new RoutingCountryDefinition();
  		c3.country = "GB";
  		c3.length = 6;
  		c3.label = "Sort Code";
  		c3.description = rb.getString( "FlexCommon", "ROUTING_NBR_UK_TIP" );
  		countries["GB"] = c3;
  	}
  	
  	/**
  	 * Returns routing display information for the specified country.
  	 * 
  	 * @param country a two-digit country code
  	 * 
  	 * @return an instance of RoutingCountryDefinition
  	 */
  	public static function getCountry( country:String ):RoutingCountryDefinition 
    {
  		return countries[ country ] as RoutingCountryDefinition;
  	}
	}
}